//
//  TLSingleton.h
//  Kaledai
//
//  Created by taolei-mac on 2017/5/16.
//  Copyright © 2017年 com.zhejiangchain.ios. All rights reserved.
//

// .h文件
#define TLSingletonH(name) + (instancetype)shared##name;

// .m文件
#define TLSingletonM(name) \
static id _instance; \
\
+ (id)allocWithZone:(struct _NSZone *)zone \
{ \
     static dispatch_once_t onceToken; \
     dispatch_once(&onceToken, ^{ \
         _instance = [super allocWithZone:zone]; \
     }); \
 \
     return _instance; \
} \
\
+ (instancetype)shared##name \
{ \
     if (_instance == nil) { \
         _instance = [[self alloc] init]; \
     } \
 \
     return _instance; \
}\
